package com.future.controller;

import java.util.ArrayList;
import java.util.List;

import com.future.common.annotation.ControllerMapping;
import com.future.common.annotation.NoNeedLogin;
import com.future.common.base.BaseController;
import com.future.common.bean.KV;
import com.future.dao.ActivityDao;
import com.future.dao.BjDao;
import com.future.dao.DiseaseDao;
import com.future.dao.FoodDao;
import com.future.dao.KinderDao;
import com.future.dao.NewsDao;
import com.future.dao.NoticeDao;
import com.future.dao.TeacherDao;
import com.future.dao.WeekFoodDao;
import com.future.model.Bj;
import com.future.model.Kginfo;
import com.jfinal.aop.Inject;

@ControllerMapping("/web")
public class WebSiteController extends BaseController {
	@Inject
	private KinderDao kinderDao;
	@Inject
	private TeacherDao teacherDao;
	@Inject
	private NewsDao newsDao;
	@Inject
	private ActivityDao activityDao;
	@Inject
	private WeekFoodDao weekFoodDao;
	@Inject
	private BjDao bjDao;
	@Inject
	private NoticeDao noticeDao;
	@Inject
	private DiseaseDao diseaseDao;
	@Inject
	private FoodDao foodDao;

	@NoNeedLogin
	public void getkinderInfo() {
		List<Kginfo> kgInfoList = kinderDao.findAll();
		Kginfo kginfo = null;
		if (kgInfoList != null && kgInfoList.size() > 0) {
			kginfo = kgInfoList.get(0);
		}
		renderResult("kinderinfo", kginfo);
	}

	@NoNeedLogin
	public void getTeachers() {
		renderResult("teachers", this.teacherDao.getTeachers());
	}

	@NoNeedLogin
	public void getNews() {
		renderResult("news", this.newsDao.findAll());
	}

	@NoNeedLogin
	public void getActivitys() {
		renderResult("activitys", this.activityDao.findAll());

	}

	@NoNeedLogin
	public void getWeekFoods() {
		renderResult("weekfood", this.weekFoodDao.getWeekFood());
	}

	@NoNeedLogin
	public void getBjs() {
		List<Bj> bjList = this.bjDao.findAll();
		List<KV> bjcodeList = new ArrayList<KV>();
		for (Bj bj : bjList) {
			KV bjKV = new KV(bj.getClassname(), bj.getClassid().toString());
			bjcodeList.add(bjKV);
		}
		renderResult("bjlist", bjcodeList);
	}

	@NoNeedLogin
	public void getNotices() {
		renderResult("notices", this.noticeDao.findAll());
	}

	@NoNeedLogin
	public void getDiseases() {
		renderResult("diseases", this.diseaseDao.findAll());
	}

	@NoNeedLogin
	public void getFoods() {
		renderResult("foods", this.foodDao.findAll());
	}
}
